package bestTeam.WalkieDoggie.server.Persistant;

import java.util.ArrayList;
import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import bestTeam.WalkieDoggie.client.walkieStatus;
import bestTeam.WalkieDoggie.client.Serializables.UserRequest;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class PersistantRequest {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key rid;
	//the id of the user who created this request
	@Persistent
	private String createdBy;
	//the name of the user who created this request
	@Persistent
	private String userName;
	//Id of the user that was approved for this request
	@Persistent
	private String approvedWalkerID;
	@Persistent
	private Date createDate;
	@Persistent
	private Date walkTime;
	@Persistent
	private String timeFrame;
	@Persistent
	private String message;
	@Persistent
	private ArrayList<String> volunteersId;
	@Persistent
	private walkieStatus status;
	@Persistent
	private Date creationDate;
	@Persistent
	private double rank;;

	public PersistantRequest() {
		this.createDate = new Date();

	}

	public PersistantRequest(UserRequest request) {
		this();
		this.creationDate = new Date();
		this.setRank(-1);
		this.createdBy = request.getCreatedBy();
		this.userName = request.getUserName();
		this.message = request.getMessage();
		this.status = request.getStatus();
		this.approvedWalkerID = request.getApprovedWalkerID();

		String t = request.getTimeFrame();
		int hour=0;
		if(t.equals("Morning"))
			hour = 6;
		else if(t.equals("Noon"))
			hour = 12;
		else if(t.equals("Evening"))
			hour = 16;
		else if(t.equals("Night"))
			hour = 20;

		request.getDate().setHours(hour);
		this.walkTime = request.getDate();
		this.timeFrame = request.getTimeFrame();


	}

	public Key getId() {
		return this.rid;
	}

	public void setId(Key key) {
		this.rid = key;
	}

	public String getCreatedBy() {
		return this.createdBy;
	}

	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreatedBy(String userId) {
		this.createdBy = userId;
	}

	public Date getWalkTime() {
		return walkTime;
	}

	public void setWalkTime(Date walkTime) {
		this.walkTime = walkTime;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public ArrayList<String> getVolunteers() {
		return volunteersId;
	}

	public void setVolunteers(ArrayList<String> volunteers) {
		this.volunteersId = volunteers;
	}

	public String getTimeFrame() {
		return timeFrame;
	}

	public void setTimeFrame(String timeFrame) {
		this.timeFrame = timeFrame;
	}

	public walkieStatus getStatus() {
		return status;
	}

	public void setStatus(walkieStatus status) {
		this.status = status;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getApprovedWalkerID() {
		return approvedWalkerID;
	}

	public void setApprovedWalkerID(String approvedWalkerID) {
		this.approvedWalkerID = approvedWalkerID;
	}

	public double getRank() {
		return rank;
	}

	public void setRank(double rank) {
		this.rank = rank;
	}




}